package net.scribblemedia.candle.data.download;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;

import org.encog.ml.data.market.MarketDataType;
import org.encog.ml.data.market.TickerSymbol;
import org.encog.ml.data.market.loader.LoadedMarketData;
import org.encog.ml.data.market.loader.YahooFinanceLoader;

public class MarketDataDownloader {
	private Date fromDate;
	private Date toDate;
	private String symbol;
	
	public MarketDataDownloader(Date fromDate, Date toDate, String symbol) {
		this.setFromDate(fromDate);
		this.setToDate(toDate);
		this.setSymbol(symbol);
	}
	
	public List<LoadedMarketData> retrieveMarketData() {
		List<LoadedMarketData> marketData = new ArrayList<LoadedMarketData>(new YahooFinanceLoader().load(new TickerSymbol(getSymbol()), new HashSet<MarketDataType>(), getFromDate(), getToDate()));
		Collections.sort(marketData);
		return marketData;
		
	}

	public Date getFromDate() {
		return fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public Date getToDate() {
		return toDate;
	}

	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}

	public String getSymbol() {
		return symbol;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}
}
